{include file="public/toper" /}
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">订单管理</a>
        <a href="">会员卡订单</a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">&#xe666;</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <input type="text" name="sreach" value=""  style="width:250px;" id="key"   placeholder="请输入订单号/购卡人/手机号/销售人" autocomplete="off" class="layui-input">
            <div class="layui-input-inline">
                <select name="type" id="type">
                    <option value=".">全部</option>
                    <option value="0">年卡</option>
                    <option value="1">半年卡</option>
                    <option value="2">季卡</option>
                    <option value="3">月卡</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="store_name" id="store_name">
                    <option value=".">全部</option>
                    {volist name="list" id="vo"}
                    <option value="{$vo.sn}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <button class="layui-btn" id="search"><i class="layui-icon">&#xe615;</i></button>
        </div>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="sn">
    <div><a href="#"  onclick="x_admin_show('查看订单','{:url(\'admin/Corder/edit\')}?id={{d.card_order_id}}')" title="查看详情" class="layui-table-link">{{d.card_order_sn}}</a></div>
</script>
<script type="text/html" id="user">
    {{d.uname}}{{#  if(d.phone!=null){ }}【{{d.phone.substring(0,3)+"****"+d.phone.substring(7,d.phone.length) }}】{{#  } }}
</script>
<script type="text/html" id="effective">
    {{#  if(d.card_status==1){ }}{{d.pay_time}}至{{d.validity_time}}{{#  } else { }}无{{#  } }}
</script>
<script type="text/html" id="store_id">
{{d.store_user_sn}}
</script>
<script>
    layui.use(['table','util'], function(){
        var table = layui.table, $ = layui.jquery;
        var layer = layui.layer;
        var loading = layer.load(1, {shade: [0.1,'#fff'] });
        var tableIn = table.render({
            method: 'post'
            ,elem: '#test'
            ,url: "{:url('Card/index')}"
            ,id:'test'
            ,cols: [[
                {field:'card_order_id', width:80, title: '序号',align: 'center',type:'numbers'}
                ,{width: 190,title: '订单号', align: 'center', toolbar: '#sn',totalRowText:'合计'}
                ,{field:'stype', width:100, title: '会员卡类型',align: 'center',templet: function(d){if(d.stype==0){return '年卡';}else if(d.stype==1){return '半年卡';}else if(d.stype==2){ return '季卡';}else if(d.stype==3){return '月卡';}}}
                ,{width: 200,title: '购卡人', align: 'center', toolbar: '#user'}
                ,{width: 200,title: '有效期', align: 'center', toolbar: '#effective'}
                ,{field:'order_amount', width:100, title: '订单金额',align: 'center',totalRow: true}
                ,{field:'pay_price',width:100,title:'支付金额',align:'center',totalRow: true, style:"color: #FF0000;"}
                ,{width: 150,title: '销售经理', align: 'center', toolbar: '#store_id'}
                ,{field:'card_status', width:100, title: '状态',align: 'center',templet: function(d){if(d.card_status==0){return '未付款';}else if(d.card_status==1){return '已付款';}else if(d.card_status==2){return '已取消';}}}
                ,{field:'type', width:100, title: '类型',align: 'center', style:"color: #F581B1;",templet: function(d){if(d.type==0){return '线上';}else if(d.type==1){return '线下';}}}
                ,{field: 'add_time',width: 180, sort:'true',title: '下单时间', templet: '<div>{{layui.util.toDateString(d.add_time*1000) }}</div>'}
            ]]
            ,page: true
            ,limit: 30
            ,limits:[30,60,90,120,150,180,210,240,270,300]
            ,totalRow:true
        });
        layer.close(loading);

        //搜索
        $('#search').on('click', function () {
            tableIn.reload({
                where: {key: $('#key').val(),type:$('#type').val(),store_name:$('#store_name').val()}
                ,page: {curr: 1}
            });
        });
    });
</script>
{include file="public/footer"/}